package main

import (
	"fmt"
	"strings"
)

func main() {
	reader := strings.NewReader("abcdefg")
	printNext5Bytes(reader)
	for i := 0; i < 3; i++ {
		//撤销读取一个字节,可以将Reader已读取的位置进行重新定位
		reader.UnreadByte()
	}
	fmt.Println()
	printNext5Bytes(reader)
}

func printNext5Bytes(reader *strings.Reader) {
	for i := 0; i < 5; i++ {
		//读取一个字节
		readByte, _ := reader.ReadByte()
		fmt.Print(string(readByte))
	}
}
